package com.zzl.mq.network.gossip;

import java.io.Serializable;

/**
 * 数据消息的载荷类
 * 用于在集群节点间传递消息数据
 */
public class DataMessagePayload implements Serializable {
    private String topic;
    private String message;
    private long timestamp;  // 消息产生的时间戳
    
    public DataMessagePayload(String topic, String message, long timestamp) {
        this.topic = topic;
        this.message = message;
        this.timestamp = timestamp;
    }
    
    public String getTopic() {
        return topic;
    }
    
    public String getMessage() {
        return message;
    }
    
    public long getTimestamp() {
        return timestamp;
    }
    
    /**
     * 创建一个新的数据消息载荷
     * @param topic 主题
     * @param message 消息内容
     * @return 数据消息载荷对象
     */
    public static DataMessagePayload create(String topic, String message, Long timestamp) {
        return new DataMessagePayload(topic, message, timestamp == null?System.currentTimeMillis():timestamp);
    }
} 